﻿using System;
using System.Collections.Generic;
using PrearrangedChaos.AgileZen.Service.Model;
using PrearrangedChaos.AgileZen.Service.Rest;

namespace PrearrangedChaos.AgileZen.Service
{
    internal class ZenProjectCollection<TCollection> : ZenResourceCollection<TCollection, IProject>, IZenProjectEnumerable
        where TCollection : class, IPagingResponse<IProject>
    {
        public IZenProjectEnumerable WithDetails
        {
            get
            {
                AddEnrichment("details");
                return this;
            }
        }

        public IZenProjectEnumerable WithInvites
        {
            get
            {
                AddEnrichment("invites");
                return this;
            }
        }

        public IZenProjectEnumerable WithMembers
        {
            get
            {
                AddEnrichment("members");
                return this;
            }
        }

        public IZenProjectEnumerable WithMetrics
        {
            get
            {
                AddEnrichment("metrics");
                return this;
            }
        }

        public IZenProjectEnumerable WithPhases
        {
            get
            {
                AddEnrichment("phases");
                return this;
            }
        }

        public IZenProjectEnumerable WithRoles
        {
            get
            {
                AddEnrichment("roles");
                return this;
            }
        }

        public ZenProjectCollection(string apiKey, int pageSize)
            : base(apiKey, RestArguments.Project(pageSize))
        {
        }

        public IZenResourceEnumerable<IProject> Filter(Func<IProjectFilter, ZenFilter> filter)
        {
            SetFilter<ProjectFilter>(filter);
            return this;
        }
    }
}